<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <SONIA ZRIBI>
 */
class Application_Model_Tuteur extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Cin;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_FirstnameTut;

    /**
     * Database var type varchar(45)
     *
     * @var string
     */
    protected $_LastnameTut;



    /**
     * Dependent relation fk_tuteur_has_courselot_tuteur1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_TuteurHasCourselot
     */
    protected $_TuteurHasCourselot;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'cin'=>'Cin',
            'firstname_tut'=>'FirstnameTut',
            'lastname_tut'=>'LastnameTut',
        ));

        $this->setParentList(array(
        ));

        $this->setDependentList(array(
            'FkTuteurHasCourselotTuteur1' => array(
                    'property' => 'TuteurHasCourselot',
                    'table_name' => 'TuteurHasCourselot',
                ),
        ));
    }

    /**
     * Sets column cin
     *
     * @param int $data
     * @return Application_Model_Tuteur
     */
    public function setCin($data)
    {
        $this->_Cin = $data;
        return $this;
    }

    /**
     * Gets column cin
     *
     * @return int
     */
    public function getCin()
    {
        return $this->_Cin;
    }

    /**
     * Sets column firstname_tut
     *
     * @param string $data
     * @return Application_Model_Tuteur
     */
    public function setFirstnameTut($data)
    {
        $this->_FirstnameTut = $data;
        return $this;
    }

    /**
     * Gets column firstname_tut
     *
     * @return string
     */
    public function getFirstnameTut()
    {
        return $this->_FirstnameTut;
    }

    /**
     * Sets column lastname_tut
     *
     * @param string $data
     * @return Application_Model_Tuteur
     */
    public function setLastnameTut($data)
    {
        $this->_LastnameTut = $data;
        return $this;
    }

    /**
     * Gets column lastname_tut
     *
     * @return string
     */
    public function getLastnameTut()
    {
        return $this->_LastnameTut;
    }

    /**
     * Sets dependent relations fk_tuteur_has_courselot_tuteur1
     *
     * @param array $data An array of Application_Model_TuteurHasCourselot
     * @return Application_Model_Tuteur
     */
    public function setTuteurHasCourselot(array $data)
    {
        $this->_TuteurHasCourselot = array();

        foreach ($data as $object) {
            $this->addTuteurHasCourselot($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_tuteur_has_courselot_tuteur1
     *
     * @param Application_Model_TuteurHasCourselot $data
     * @return Application_Model_Tuteur
     */
    public function addTuteurHasCourselot(Application_Model_TuteurHasCourselot $data)
    {
        $this->_TuteurHasCourselot[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_tuteur_has_courselot_tuteur1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_TuteurHasCourselot
     */
    public function getTuteurHasCourselot($load = true)
    {
        if ($this->_TuteurHasCourselot === null && $load) {
            $this->getMapper()->loadRelated('FkTuteurHasCourselotTuteur1', $this);
        }

        return $this->_TuteurHasCourselot;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Tuteur
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Tuteur());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Tuteur::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getCin() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('cin = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getCin()));
    }
}
